/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package it.polimi.games.epkb.entityClasses;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author plebani
 */
@Entity
@Table(name = "data_file")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "DataFile.findAll", query = "SELECT d FROM DataFile d"),
    @NamedQuery(name = "DataFile.findById", query = "SELECT d FROM DataFile d WHERE d.id = :id"),
    @NamedQuery(name = "DataFile.findByNameAndPath", query = "SELECT d FROM DataFile d WHERE d.nameAndPath = :nameAndPath"),
    @NamedQuery(name = "DataFile.findByAccessType", query = "SELECT d FROM DataFile d WHERE d.accessType = :accessType"),
    @NamedQuery(name = "DataFile.findByFlags", query = "SELECT d FROM DataFile d WHERE d.flags = :flags")})
public class DataFile implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "ID")
    private String id;
    @Column(name = "NameAndPath")
    private String nameAndPath;
    @Column(name = "AccessType")
    private String accessType;
    @Column(name = "Flags")
    private String flags;
    @ManyToMany(mappedBy = "dataFileCollection")
    private Collection<Component> componentCollection;
    @OneToMany(mappedBy = "idDataFile")
    private Collection<Annotation> annotationCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "dataFile")
    private Collection<ActivityData> activityDataCollection;

    public DataFile() {
    }

    public DataFile(String id) {
        this.id = id;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getNameAndPath() {
        return nameAndPath;
    }

    public void setNameAndPath(String nameAndPath) {
        this.nameAndPath = nameAndPath;
    }

    public String getAccessType() {
        return accessType;
    }

    public void setAccessType(String accessType) {
        this.accessType = accessType;
    }

    public String getFlags() {
        return flags;
    }

    public void setFlags(String flags) {
        this.flags = flags;
    }

    @XmlTransient
    public Collection<Component> getComponentCollection() {
        return componentCollection;
    }

    public void setComponentCollection(Collection<Component> componentCollection) {
        this.componentCollection = componentCollection;
    }

    @XmlTransient
    public Collection<Annotation> getAnnotationCollection() {
        return annotationCollection;
    }

    public void setAnnotationCollection(Collection<Annotation> annotationCollection) {
        this.annotationCollection = annotationCollection;
    }

    @XmlTransient
    public Collection<ActivityData> getActivityDataCollection() {
        return activityDataCollection;
    }

    public void setActivityDataCollection(Collection<ActivityData> activityDataCollection) {
        this.activityDataCollection = activityDataCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DataFile)) {
            return false;
        }
        DataFile other = (DataFile) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "it.polimi.games.epkb.entityClasses.DataFile[ id=" + id + " ]";
    }
    
}
